using System;
using System.Collections.Generic;
using System.Collections;
using System.Text;
using System.Drawing; 
using BuildingBasicDomain;
using CommonTypes;
using CommonTypes.Events ;
using System.ComponentModel;
using MVCFramework;

namespace BuildingStructuralElements
{
    [Serializable ]
    public class DrawingObject // : MVCFramework .GlobalizedObject 
    {
        # region "Drawing Attributes"

        public string XmlDataPath = "";

        private double dx, dy, dz;
        private double angleX, angleY, angleZ;
        private Color color;
        private double alpha = 0.8;

        private string name;
        private bool showName;
        private Color textColor = System.Drawing.Color.Red;

        [NonSerialized]
        public bool needsUpdate;

        [NonSerialized]
        public Hashtable HashTable;

        #region Properties


        [Description("Element Color"), Category("Color")]
        public virtual Color ElementColor
        {
            set { color = value; }
            get { return color; }
        }

        [Description("Alpha"), Category("Color")]
        public virtual double Alpha
        {
            set { alpha = value; }
            get { return alpha; }
        }

        [Description("Element Angle X Axis"), Category("Position")]
        public virtual double AngleX
        {
            set { angleX = value; }
            get { return angleX; }
        }

        [Description("Element Angle Y Axis"), Category("Position")]
        public virtual double AngleY
        {
            set { angleY = value; }
            get { return angleY; }
        }

        [Description("Element Angle Z Axis"), Category("Position")]
        public virtual double AngleZ
        {
            set { angleZ = value; }
            get { return angleZ; }
        }

        [Description("Displacement X"), Category("Position")]
        public virtual double Dx
        {
            set { dx = value; }
            get { return dx; }
        }

        [Description("Displacement Y"), Category("Position")]
        public virtual double Dy
        {
            set { dy = value; }
            get { return dy; }
        }

        [Description("Displacement Z"), Category("Position")]
        public virtual double Dz
        {
            set { dz = value; }
            get { return dz; }
        }


        [Description("Element Name")]
        public virtual string Name
        {
            set { name = value; }
            get { return name; }
        }

        [System.ComponentModel.Browsable(false)]
        //[Description("Show Name"), Category("Name")]
        public bool ShowName
        {
            set { showName = value; }
            get { return showName; }
        }

     //   [Description("Text Color"), Category("Name")]
        [System.ComponentModel.Browsable(false)]
        public Color TextColor
        {
            set { textColor = value; }
            get { return textColor; }
        }

      //  [Description("Selection Color"), Category("Color")]
        [System.ComponentModel.Browsable(false)]
        public Color SelectionColor
        {
            set { textColor = value; }
            get { return textColor; }
        }


        #endregion

        #endregion
    }

    [Serializable ]
    public abstract class StructuralElement :DrawingObject, ISelectable,ICountable, IModelData ,IModifiable
    {

       // CommonTypes .Math .Matrix3D rxm = new CommonTypes.Math.Matrix3D (

        public event CreationHandler OnCreate;
        public event EventHandler OnModify;

        protected  StructuralElement()
        {
            if (OnCreate != null)
                OnCreate(this, new CreationEventArgs());
        }

        # region " IModifiable Implementation " 

        public abstract bool Move(Vector v);

        public abstract bool Move(double dx, double dy, double dz);

        # endregion 

        # region " ISelecatble ,Icountable  Implemantaion "

        protected  bool isSelected;
        public virtual bool IsSelected
        {
            get { return isSelected; }
            set { this.isSelected = value; }
        }
        
        protected int id;
        public virtual int Id
        {
            get { return this.id; }
            set { this.id = value; }
        }

        # endregion
        

    }

    public class StructuralException : Exception
    {
        public StructuralException(string message) : base(message) { }
        public StructuralException(string message, Exception inner) : base(message, inner) { }
        public StructuralException() : base() { }
    }
    
}
